# $Id: PKGBUILD 80139 2012-11-16 17:14:04Z lfleischer $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Andrea Zucchelli <zukka77@gmail.com>

pkgname=tinyproxy
pkgver=1.8.3
pkgrel=6
pkgdesc='A light-weight HTTP proxy daemon for POSIX operating systems.'
arch=('i686' 'x86_64')
url='https://banu.com/tinyproxy/'
license=('GPL')
makedepends=('asciidoc')
install="${pkgname}.install"
backup=('etc/tinyproxy/tinyproxy.conf')
source=("https://banu.com/pub/${pkgname}/1.8/${pkgname}-${pkgver}.tar.bz2"
        'tinyproxy'
        'tinyproxy.tmpfiles.conf'
        'tinyproxy.service')
md5sums=('292ac51da8ad6ae883d4ebf56908400d'
         '90eb2b3371e56d5a784fd826d4a6e5f8'
         '3c2764578f26581346fe312da0519a3e'
         '299ca484c08d9873c74e1eb96f6a5cc0')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ./configure --prefix=/usr --sysconfdir=/etc/tinyproxy --localstatedir=/var --enable-transparent
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install
  install -Dm0755 "${srcdir}/tinyproxy" "${pkgdir}/etc/rc.d/tinyproxy"
  install -Dm0644 "${srcdir}/tinyproxy.tmpfiles.conf" "${pkgdir}/usr/lib/tmpfiles.d/tinyproxy.conf"

  install -dm0755 -o nobody -g nobody "${pkgdir}/var/log/${pkgname}"

  # Provide sane defaults
  sed -i '/^#Listen/a\Listen 127.0.0.1' "${pkgdir}/etc/tinyproxy/tinyproxy.conf"

  install -Dm0644 "${srcdir}/tinyproxy.service" \
    "${pkgdir}/usr/lib/systemd/system/tinyproxy.service"
}
